<template>
    <el-container  v-loading="loading">
        <el-header> 
            <span @click="returns" style='cursor:pointer'><img src='../../assets/logo.png' style='width:32px;float:left;vertical-align:middle;margin-top:15px;margin-right:10px;'/>{{title1}}</span>
            <div class='model'>
                <div :class='item.className' v-for="(item,index) in desktopMain" :key="index" @click="changeMenu(index)">
                    <div style='position:relative'>
                        <i class="fa fa-briefcase" aria-hidden="true"></i><span class='model_span'>{{item.text}}</span>
                        <div class="kailong"></div>
                    </div>
                </div>
            </div>
            <div class='user' >
                <div id="DateTime" style='display:inline;margin-right:15px;'></div>
                 <el-divider direction="vertical"></el-divider>
                <span style='margin-right:15px;margin-left:15px'>{{title2}}</span>
                 <el-divider direction="vertical"></el-divider>
                <i class='fa fa-user-circle' style='margin-left:15px'></i>
                &nbsp;
                <el-dropdown>
                    <span class="el-dropdown-link" style='color:#fff;font-size:14px;cursor:pointer;'>
                        {{username}}<i class='el-icon-arrow-down' style='margin-left:5px;'></i>
                    </span>
                    
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item icon="el-icon-lock" @click.native="updatePwd()">修改密码</el-dropdown-item>
                        <el-dropdown-item icon="el-icon-user" @click.native="logout()">退出登陆</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </el-header>
        <el-container >
            <el-aside width="200px" v-if="isFolder=='N'">
                <div class='content_item' v-for="(item,index) in desktop" :key="index" v-on:click="openUrl(item)" >
                    <!--img :src='item.icon'>
                    <div>{{item.text}}</div-->
                    <div><i class="fa fa-briefcase" aria-hidden="true" style='margin-right:10px;vertical-align: middle'></i>{{item.text}}</div>
                </div>
            </el-aside>
             <el-aside width="200px" v-if="isFolder=='Y'">
                 <el-collapse  v-model="activeName">
                    <el-collapse-item v-for="(item,index) in desktop" :key="index" :name="index">
                        <template slot="title">
                        <i :class='item.fa' style='margin-right:5px'></i>{{item.text}}
                        </template>
                        <!--div class='content_item' v-for="(child,index2) in item.children" :key="index2" v-on:click="openUrl(child)" >
                            <img :src='child.icon'>
                            <div>{{child.text}}</div>
                        </div-->
                        <div class='content_item' v-for="(child,index2) in item.children" :key="index2" v-on:click="openUrl(child)" >
                            
                            <div><i class="fa fa-briefcase" aria-hidden="true" style='margin-right:10px;vertical-align: middle'></i>{{child.text}}</div>
                        </div>
                    </el-collapse-item>
                </el-collapse>
            </el-aside>
            <el-main v-loading="loading2">
                <div class='el-main-content'>
                    <div class='headers' style='display:none'>
                        <el-breadcrumb separator="/">
                        <el-breadcrumb-item v-for="(item,index) in bar" :key="index">
                            <a :href="item.url">{{item.text}}</a>
                        </el-breadcrumb-item>
                    
                        </el-breadcrumb>
                    </div>

                    <div class='eltabs' style='height:46px;'>
                        <el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab" @tab-click="tabClick"  :before-leave="beforeLeaveTab"> 
                            <el-tab-pane
                                v-for="(item) in editableTabs"
                                :key="item.name"
                                :label="item.title"
                                :name="item.name"
                            >
                                
                            </el-tab-pane>
                        </el-tabs>
                    </div>
                    <div class="el-tabs__content2" v-loading="routerLoading">
                        <keep-alive>
                            <router-view :key="key"  @openWin="openWin" @closeWin="closeWins" @goSearch="goSearch" ref="routers"></router-view>
                        </keep-alive>
                    </div>
                </div>
                
                
                

                <el-dialog
                v-el-drag-dialog
                :title="item.text"
                :modal="false"
                class="dialogClass"
                :visible.sync="item.dialogVisible"
                :width="item.width" :height="item.height" v-for="(item,index) in windowModel" :key="index">
                
                    <iframe id="iframe" name="iframe" :src="item.url"  class='dialogIframe'  frameborder="no" border="0" marginwidth="0" marginheight="0" style='width:100%'></iframe>
        
                
            </el-dialog>
            <el-dialog
                v-el-drag-dialog
                title="二级菜单"
                :modal="false"
                class="dialogClass"
                width="30%"
                :visible.sync="dialogVisible2"
                >
                <el-row v-for="(item,index) in buttonJson" :key="index" style='margin-top:15px'>
                     <el-col :span="24">
                        <el-button type="primary"   @click="openWin(item)"  style='width:100%'>{{item.buttonName}}</el-button>
                     </el-col>
                </el-row>
                
            </el-dialog>

            <el-dialog
            title="修改密码"
            :visible.sync="dialogVisible"
            width="30%"
            >
            
            <el-form ref="form"  label-width="80px">
                <el-form-item label="旧密码">
                    <el-input v-model="oldPwd" show-password></el-input>
                </el-form-item>
            </el-form>
             <el-form ref="form"  label-width="80px">
                <el-form-item label="新密码">
                    <el-input v-model="newPwd" show-password></el-input>
                </el-form-item>
            </el-form>
             <el-form ref="form"  label-width="80px">
                <el-form-item label="确认密码">
                    <el-input v-model="newPwd2" show-password></el-input>
                </el-form-item>
            </el-form>
             <el-alert
                title="密码中必须包含字母（不区分大小写）、数字，至少8个字符，最多30个字符"
                type="error"
                show-icon>
            </el-alert>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="updatePwdHt">确 定</el-button>
            </span>
            </el-dialog>

            </el-main>
        </el-container>
    </el-container>

</template>
<script>
import TabComponent  from '../../components/common/TabComponent'
export default {
    components: { 
        TabComponent
    },
    data(){
        return{
            dialogVisible2:false,
            modelId:'',
            activeName:0,
            desktop:[],
            desktopMain:[],
            title:'',
            title1:'',
            title2:'',
            titles:'',
            oldId:'',
            oldtitle:'',
            bar:[],
            loading:false,
            loading2:false,
            editableTabs:[],
            editableTabsValue:'',
            editableTabsOldValue:'',
            routerAlive:true,//目前不用
            key:'',//用于router-view，切换的时候重新加载
            isGoSearch:'N',//已经不用
            oldPwd:'',
            newPwd:'',
            newPwd2:'',
            isClose:'N',
            dialogVisible:false,
            isFolder:'N',//看是否启用二级菜单，目前最多二级
            wins:{},//记录子页面是由哪个父页面url打开的，解决保存刷新问题
            goSearchWin:[],//哪些窗口需要刷新,解决保存刷新问题
            closeWin:[],//哪些窗口被关闭，解决下一次打开的时候，还是老界面
            winTops:{},//记录各个页面的滚动条，好方便切换回来的时候，列表界面滚动条还在老位置
            scrollTop:'',//当前页面的滚动条位置
            winKey:[],//记录各个页面的router key值，主要是针对commonEdit页面，关闭后新打开的页面加了时间戳，但切换选项卡的时候，没有记录这个时间戳导致key又变成没有时间戳的那个key
            winRecord:{},
            windowModel:[{
                text:'',
                dialogVisible:false,
                width:'',
                height:'',
                url:''
            }],
            buttonJson:[],
            username:'',
            routerLoading:false
        }
    },
    created(){
        let sef=this;
         window.setInterval(function(){
            sef.fnDate();
        },1000);
        this.username=localStorage.getItem("username");
        this.title = this.$route.query.title;

        this.title2=this.title;
        this.title1=this.oldtitle;
        document.title=this.title;
        this.modelId = this.$route.query.modelId;
        if(this.$route.query.titles)
        this.titles = this.$route.query.titles;
        let titles_=this.titles.split(",");
        let modelIds_ = this.$route.query.modelIds;
        if(modelIds_)
            modelIds_=modelIds_.replace(","+this.modelId,"");
        let modelIds="";
        if( this.$route.query.modelIds)
            modelIds = this.$route.query.modelIds.split(",");
        this.oldId=this.$route.query.oldId;
        this.oldtitle=this.$route.query.oldtitle;
        let titles__="";
        for(let i=0;i<titles_.length;i++){
            let bar_={};
            bar_.text=titles_[i];
            if(i==0){
                bar_.url="/main?title="+bar_.text;
            }else{
                if(modelIds.length>i){
                    bar_.url="/main?title="+bar_.text+"&modelId="+modelIds[i]+"&modelIds="+modelIds_+"&titles="+titles__;
                }
            }

            titles__=titles__=="" ? titles_[i]:titles__+","+titles_[i];
            this.bar.push(bar_);
            if(i==titles_.length-2){
                this.title=titles_[i]+'/'+this.title;
            }
        }
         /*window.addEventListener('message', function(messageEvent) {
                var data = messageEvent.data;
                let item=JSON.parse(data);
                if(item.type=='close')
                    sef.closeWin();
                else if(item.type=="goSearch"){
                    let els=document.getElementsByTagName("iframe");
                    for(let i=0;i<els.length;i++){
                        try{
                            window.frames[i].postMessage("goSearch",'*');
                        }catch(e){console.log(e.message)}
                    }
                    //window.contentIframe.postMessage("goSearch",'*');
            } else
                    sef.openWin(item)
            // vue.menuTitle = data;
            },false);*/
       this.loadData(true);
    },
    updated(){
      if(this.desktop.length==0){
          this.loadData(true);
      }
       if(this.$route.query.oldId)
        this.oldId=this.$route.query.oldId;
        if(this.$route.query.oldtitle)
       this.oldtitle=this.$route.query.oldtitle;
        this.title = this.$route.query.title;
        if(this.$route.query.titles)
            this.titles = this.$route.query.titles;

       
        this.title2=this.title;
        this.title1=this.oldtitle;
    },
    methods:{
        goSearch(data){
            let datas=JSON.parse(data);
            let url=this.wins[this.editableTabsValue];
            this.goSearchWin.push(url);
        },
        beforeLeaveTab(){
            if(this.isClose!='Y'){
                this.editableTabsOldValue=this.editableTabsValue;
            }else
                this.isClose='N';
            
        },
        initScroll(){
            let scrollTop=0;
          
            try{
                scrollTop=this.$refs.routers.getScrollTop();
               
                this.winTops[this.getKeys(this.editableTabsOldValue)]=scrollTop;
                //this.scrollTop=this.winTops[this.getKeys(this.editableTabsValue)]
            }catch(e){
                this.scrollTop=0;
            }
           
        },
        getKeys(path){
            let params={};
            let index=path.indexOf("?");
            let path_=path.substring(index+1).split("&");
            for(let i=0;i<path_.length;i++){
                let param=path_[i].split("=");
                params[param[0]]=param[1];
            }
            return params["sKey"];
        },
        tabClick(tab){
            
            let path = tab.name;
           /* if(this.isGoSearch=='Y'){
                var timestamp = (new Date()).getTime()/1000;
                path=path+"&timestamp="+timestamp;
                this.isGoSearch='N';
            }*/
            
            //this.editableTabsOldValue=this.editableTabsValue;//在离开的时候，已经赋值了，这里不用了，赋值反而有问题
            if(path!=this.editableTabsOldValue){
                this.editableTabsValue=path;
                this.loadTab2(path);
            }
           
        },
        loadTab(path){
            this.routerAlive=false;
            console.log(path)
            path=path.replace("/list","/byg/tabMain/list")
            path=path.replace("/listComplex","/byg/tabMain/listComplex")
            path=path.replace("/listDouble","/byg/tabMain/listDouble")
            path=path.replace("/cemetery","/byg/tabMain/cemetery")
            path=path.replace("/optionSet","/byg/tabMain/optionSet")
            if(path.indexOf("http://")!=-1){
                path="/byg/tabMain/extendUrl?url="+escape(escape(path));
            }
            path=path+"&modelId="+this.modelId+"&title="+this.title+"&oldId="+this.oldId+"&oldtitle="+this.oldtitle
            var timestamp = (new Date()).getTime()/1000;
           // path=path+"&timestamp="+timestamp;
            this.key=path;
            this.routerAlive=true;
            this.key=this.editableTabsValue;
            this.initScroll();
            if (this.$route.path !== path) {
                 this.$router.push({path: path});
            }
           
        },
        loadTab2(path){

            let isGoSearch="N";
            let goSearchIndex=-1;
            let isEdit="N";

            for(let i=0;i<this.goSearchWin.length;i++){
                if(this.goSearchWin[i]==path){
                    isGoSearch='Y';
                    goSearchIndex=i;
                }
            }
            if(goSearchIndex>=0){
                this.goSearchWin.splice(goSearchIndex,1);
            }

            let isCloses="N";
            let closeIndex=-1;
            for(let i=0;i<this.closeWin.length;i++){
                if(this.closeWin[i]==path){
                    isCloses='Y';
                    closeIndex=i;
                }
            }
           
            if(closeIndex>=0){
                this.closeWin.splice(closeIndex,1);
            }
            if(path.indexOf("commonEdit")!=-1&&isCloses=='Y'){
                isEdit="Y";
            }
            let isList="N";
            if(path.indexOf("list")!=-1){
                isList="Y";
            }
            this.routerAlive=false;
            path=path.replace("/list","list")
            path=path.replace("/listComplex","listComplex")
            path=path.replace("/listDouble","listDouble")
            path=path.replace("/commonPrint","commonPrint")
            path=path.replace("/commonEdit","commonEdit")
            path=path.replace("/cemetery","cemetery")
            if(path.indexOf("http://")!=-1){
                path="extendUrl?url="+escape(escape(path));
            }
            path=path+"&modelId="+this.modelId+"&title="+this.title+"&oldId="+this.oldId+"&oldtitle="+this.oldtitle;
            var timestamp = (new Date()).getTime()/1000;
            let key=this.editableTabsValue;
            
            if(this.winKey[this.editableTabsValue]&&isEdit!="Y"){
                key=this.winKey[this.editableTabsValue];
            }
            
            if(isEdit=='Y'){
                key=key+"&timstamp="+timestamp;
            }
            this.winKey[this.editableTabsValue]=key;
            /*if(this.isGoSearch=='Y'){
                var timestamp = (new Date()).getTime()/1000;
                path=path+"&timestamp="+timestamp;
                this.isGoSearch='N';
            }*/
          
           this.initScroll();
           this.scrollTop=this.winTops[this.getKeys(this.editableTabsValue)];
           
            let params={};
            let index=path.indexOf("?");
            let path_=path.substring(index+1).split("&");
            for(let i=0;i<path_.length;i++){
                let param=path_[i].split("=");
                params[param[0]]=param[1];
            }
            
            this.key=key;
            this.routerAlive=true;
            console.log("path==="+path);
            console.log("path==="+params);
            this.$router.push({path: path.substring(0,index),query:params});
            //this.$refs.list.scrollTop=this.scrollTop;
            let sef=this;
            if(isList=='Y'&&isCloses=='N')
                this.routerLoading=true;
            window.setTimeout(function(){
                 try{
                    /*if(isList=='Y'){
                        console.log("winRecord====="+params.sKey);
                        console.log(ef.winRecord)
                        if(sef.winRecord[params.sKey]!='Y'){
                            sef.$refs.routers.setParams(params)
                            sef.winRecord[params.sKey]='Y'
                        }
                    }*/
                    try{
                        if(isCloses=='N'){
                            sef.$refs.routers.setScrollTop(sef.scrollTop)
                        
                        }else{
                            sef.$refs.routers.initData();
                        }
                    }catch(e){}
                   
                    if(sef.routerLoading){
                        sef.routerLoading=false;
                    }
                    
                    if(isGoSearch=='Y'){
                        console.log("goSearchs--s-s-s-s-")
                        sef.$refs.routers.goSearch()
                    }
                }catch(e){}
            },1000)
           
           
         //   try{
                
          //  }catch(e){}
        },
        loadData(isOk){
             let imgIp=localStorage.getItem("imgIp");
            let sef=this;
            /**获取桌面模块，目前定义所有的模块显示，没有设置自主模块 */
            this.$post('api','api/model/getUserModelsByVue',{modelId:this.modelId,company:escape(localStorage.getItem("company"))}).then(res=>{
           
                let nav=res[0].nav;
                sef.desktop=[];
                sef.desktopMain=[];
                sef.isFolder=res[0].isFolder;
                sef.isFolder="Y"
                console.log("nav================================");
                console.log(nav);
                for(let i=0;i<nav.length;i++){
                    let n=nav[i];
                    n.icon=imgIp+n.icon;
                    for(let h=0;h<n.children.length;h++){
                        n.children[h].icon=imgIp+n.children[h].icon;
                    }
                    let className="model_item";
                    if(i==0)
                        className="model_item model_active";
                    n.className=className;
                    sef.desktopMain.push(n);
                    if(isOk){
                        if(i==0){
                            if(sef.isFolder=="N"){
                                if(n.url.indexOf("ip/")!=-1){
                        
                                    const token=sessionStorage.getItem("token");
                                    let ip=localStorage.getItem("ip");
                                    n.url=n.url.replace("ip",ip);
                                    n.url=n.url.indexOf("?")==-1 ? n.url+"?token="+token:n.url+"&token="+token;
                                }
                                let data={};
                                data.name=n.url;
                                data.title=n.text;
                                data.src=n.url;
                                sef.editableTabs=[];
                                sef.editableTabs.push(data);
                                sef.editableTabsValue=n.url;
                                let path = n.url;
                            
                                this.loadTab(path);
                            //  this.$router.push({path: n.url});
                            }else{
                                if(n.url.indexOf("ip/")!=-1){
                        
                                    const token=sessionStorage.getItem("token");
                                    let ip=localStorage.getItem("ip");
                                    n.children[0].url=n.children[0].url.replace("ip",ip);
                                    n.children[0].url=n.children[0].url.indexOf("?")==-1 ? n.children[0].url+"?token="+token:n.children[0].url+"&token="+token;
                                }

                                let data={};
                                data.name=n.children[0].url;
                                data.title=n.children[0].text;
                                data.src=n.children[0].url;
                                sef.editableTabs=[];
                                sef.editableTabs.push(data);
                                sef.editableTabsValue=n.children[0].url;
                                
                                let path = n.children[0].url;
                            
                                this.loadTab(path);
                                //this.$router.push({path: n.children[0].url});
                            }
                            
                        }
                    }
                    
                    sef.loading2=false;
                }
                
                //sef.desktop.push(sef.desktopMain[0]);
                sef.changeMenu(0);
                sef.loading=false;
            });

           
        },
        handleNodeClick(data) {
        },
        openUrl(item){
            this.src=item.url;
            this.addTab(item)
        },
        removeTab(targetName) {
            let tabs = this.editableTabs;
            let activeName = this.editableTabsValue;
           
            this.closeWin.push(activeName);
            if (activeName === targetName) {
                tabs.forEach((tab, index) => {
                    if (tab.name === targetName) {
                    let nextTab = tabs[index + 1] || tabs[index - 1];
                    if (nextTab) {
                        activeName = nextTab.name;
                    }
                    }
                });
            }
            this.isClose="Y";
            //this.isGoSearch="Y";
            this.editableTabsValue = activeName;
            this.loadTab2(this.editableTabsValue)
            this.editableTabs = tabs.filter(tab => tab.name !== targetName);
            let index=this.editableTabs.length-2;
            index=index<0 ? 0:index;
            this.editableTabsOldValue=this.editableTabs[index].src;
        },
        openWin(item){
            item=JSON.parse(item);
            
            /*let width=item.width;
            let height=item.height;
            width=width=="" ? "90%":width;
            height=height=="" ? ""+(document.documentElement.clientHeight*0.84):height;
            width=width.indexOf("%")==-1 ? width+"px":width;
            height=height.indexOf("%")==-1 ? height+"px":height;
            this.windowModel[0]['dialogVisible']=true;
            this.windowModel[0]['url']=item.url;
            this.windowModel[0]['text']=item.buttonName;
            this.windowModel[0]['icon']=item.icon;
            this.windowModel[0]['width']=width;
            this.windowModel[0]['height']=height;
            this.windowModel[0]['id']=item.id;
            this.bindDialogEvent(0);*/
            if(item.child&&item.child.length>0){
                this.dialogVisible2=true;
                this.buttonJson=item.child;
            }else{
                item.text=item.buttonName;
                this.addTab(item)
                this.dialogVisible2=false;
            }
            

        },
        addTab(item) {
            let isOpen=true;
            if(item.url.indexOf("ip/")!=-1){
                
                const token=sessionStorage.getItem("token");
                let ip=localStorage.getItem("ip");
                item.url=item.url.replace("ip",ip);
                item.url=item.url.indexOf("?")==-1 ? item.url+"?token="+token:item.url+"&token="+token;
            }
            for(let i=0;i<this.editableTabs.length;i++){
                let names=this.editableTabs[i].name;
                if(names==item.url){

                    this.editableTabs[i].src=item.url;
                    isOpen=false;
                }
            }
            if(isOpen){
                this.editableTabs.push({
                    title: item.text,
                    name: item.url,
                    src: item.url
                });
            }
            this.isClose="Y";
            this.editableTabsOldValue=this.editableTabsValue;
            this.editableTabsValue = item.url;
            // var timestamp = (new Date()).getTime()/1000;
            //let url=item.url+"&timestamp2="+timestamp;
            
            this.wins[this.editableTabsValue]=this.editableTabsOldValue;
            this.loadTab2(item.url);
        },
         bindDialogEvent(i){/**窗口初始化事件 */
            let sef=this;
            window.setTimeout(function(){
                let el=document.getElementsByClassName("el-dialog__wrapper")[i];
                const dialogEl = el.querySelector('.el-dialog');
                const dialogHeaderEl = el.querySelector('.el-dialog__header');
                const dialogBodyEl =   el.querySelector('.el-dialog__body');
                const dialogFooterEl = el.querySelector('.el-dialog__footer');
                const minmax = el.querySelector('.el-dialog__minmax');
                const closebtn = el.querySelector('.el-dialog__close');
                dialogBodyEl.style.height=sef.windowModel[i].height;
                let height=document.documentElement.clientHeight;
                let height2=Number(sef.windowModel[i].height.replace("px",""));
                let mTop=((height-height2-60)/2);
                mTop=mTop<0 ? 30:mTop
                dialogEl.style.marginTop=mTop+'px';

                
                /**为了解决点击后面的窗口让其可以在最前面显示 */
                el.style.pointerEvents="none";
                dialogHeaderEl.style.pointerEvents="auto";
                dialogBodyEl.style.pointerEvents="auto";
                if(dialogFooterEl)
                    dialogFooterEl.style.pointerEvents="auto";
                dialogBodyEl.onclick=function(){
                    let zIndex=sef.changeIndex();
                    document.getElementsByClassName("el-dialog__wrapper")[i].style.zIndex=zIndex;
                }
               
                if(dialogFooterEl){
                     dialogFooterEl.onclick=function(){
                        let zIndex=sef.changeIndex();
                        document.getElementsByClassName("el-dialog__wrapper")[i].style.zIndex=zIndex;
                    }
                }
                minmax.onclick=function(){
                   
                    sef.windowModel[i]["dialogVisible"]=false;
                }
                closebtn.onclick=function(){
                    sef.windowModel[i]["dialogVisible"]=false;
                    sef.windowModel[i]["isUse"]="N";
                    sef.windowModel[i]["url"]="";
                    sef.windowModel[i]["text"]="";
                    sef.windowModel[i]["icon"]="";
                    sef.barList.splice(i,1);
                }
                dialogBodyEl.style.padding="0";

                document.getElementById("iframe").style.height=sef.windowModel[i].height;
                
            },1000)
        },
        closeWins(){
           /* let sef=this;
            sef.windowModel[0]["dialogVisible"]=false;
            sef.windowModel[0]["isUse"]="N";
            sef.windowModel[0]["url"]="";
            sef.windowModel[0]["text"]="";
            sef.windowModel[0]["icon"]="";
            sef.barList.splice(i,1);*/
            
            this.closeWin.push(this.editableTabsValue);
            let index=-1;
            for(let i=0;i<this.editableTabs.length;i++){
                if(this.editableTabs[i].name==this.editableTabsValue){
                    index=i;
                }
            }
            this.editableTabs.splice(index,1);
            if(this.editableTabsOldValue){
                let isOk=false;
                for(let i=0;i<this.editableTabs.length;i++){
                    if(this.editableTabs[i].name==this.editableTabsOldValue){
                        isOk=true;
                    }
                }
                if(!isOk){
                    this.editableTabsOldValue=this.editableTabs[this.editableTabs.length-1].src;
                }

                this.editableTabsValue=this.editableTabsOldValue;
                let index=this.editableTabs.length-2;
                index=index<0 ? 0:index;
                this.editableTabsOldValue=this.editableTabs[index].src;
            }else{
                this.editableTabsValue=this.editableTabs[this.editableTabs.length-1].src;
                let index=this.editableTabs.length-2;
                index=index<0 ? 0:index;
                this.editableTabsOldValue=this.editableTabs[index].src;
            }
            
            this.loadTab2(this.editableTabsValue)
        },
        changeMenu(index){
            this.desktop=[];
            if(this.desktopMain[index].children[0].children.length>1){
               
                this.desktop=this.desktopMain[index].children;
                this.isFolder="Y";
            }else{
                 this.desktop=this.desktopMain[index].children;
                this.isFolder="N";
            }
            for(let i=0;i<this.desktopMain.length;i++){
                let className="model_item";
                if(i==index)
                    className="model_item model_active";
                this.desktopMain[i].className=className;
            }
            
        },
        returns(){
            //.log("returns===="+"/main?title="+this.oldtitle+"&modelId="+this.oldId+"&titles="+this.titles)
            this.$router.push({path:"/main?title="+this.oldtitle+"&modelId="+this.oldId+"&titles="+this.titles});
           // window.location.href=this.bar[this.bar.length-2].url;
        },
        logout(){
           this.$router.push({path:"/login"});
            sessionStorage.setItem("token","");
            localStorage.setItem("username","");
            localStorage.setItem("userId","");
            localStorage.setItem("company","");
        },
        updatePwd(){
            this.oldPwd="";
            this.newPwd2="";
            this.newPwd="";
            this.dialogVisible=true;

        },
        updatePwdHt(){
            let isOk=true;
            if(this.newPwd==''){
                isOk=false;
                this.$alert("密码不能为空", '提示', {
                    confirmButtonText: '确定',
                    callback: action => {
                        
                    }
                });
            }
            if(this.newPwd!=this.newPwd2&&isOk){
                isOk=false;
                this.$alert("两次密码不一致，请检查", '提示', {
                    confirmButtonText: '确定',
                    callback: action => {
                        
                    }
                });
            }
            var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z]).{8,30}')
            if (!pwdRegex.test(this.newPwd)&&isOk) {
                isOk=false;
                this.$alert("密码必须包含字母和数字，并且要大于8位数", '提示', {
                    confirmButtonText: '确定',
                    callback: action => {
                        
                    }
                });
            }
            if(isOk){
                 this.$post("userApi/updatePwd",{oldPwd:this.oldPwd,newPwd:this.newPwd}).then(data=>{
                     this.$alert(data[0].msg, '提示', {
                        confirmButtonText: '确定',
                        callback: action => {
                            if(data[0].status=="+OK"){
                                this.dialogVisible=false;
                            }
                        }
                    });
                     
                })
            }
        },
        fnDate() {
            
            var oDiv = document.getElementById("DateTime");
            var date = new Date();
            var year = date.getFullYear();//当前年份
            var month = date.getMonth();//当前月份
            var data = date.getDate();//天
            var hours = date.getHours();//小时
            var minute = date.getMinutes();//分
            var second = date.getSeconds();//秒
            var time =  this.fnW(hours) + ":" + this.fnW(minute);
            var a = new Array("日", "一", "二", "三", "四", "五", "六");
            var week = new Date().getDay();
            var str = "周" + a[week];
            oDiv.innerHTML = year + "-" + this.fnW((month + 1)) + "-" + this.fnW(data) + " "+ time + "　" + str+" ";
        },
        //补位 当某个字段不是两位数时补0
        fnW(str){
            return str > 9 ?  str :  "0" + str;}
        
    }
}
</script>
<style scoped>
.el-container{
    height:100VH;
    overflow:hidden;
    background:#e1e9f1;
}
.el-header{
    background:#3687e1;
    color:#fff;
    display: flex;
    flex-direction: row;
}
.model{
    flex:1;
    padding-left:100px;
}
.model_item{
    display:inline-block;
    padding-left:25px;
    padding-right:25px;
    cursor: pointer;
}
.model_item:hover{
     background:#1c4b8a;
    color:#00e8ff;
}
.model_item i{
    vertical-align: middle;
}
.model_span{
    margin-left:10px;
    font-size:14px;
}
.model_active{
    background:#1c4b8a;
    color:#00e8ff;
}
.model_active .kailong{

	width:0;
    height:0;
	border-right:10px solid transparent;
	border-left:10px solid transparent;
	border-bottom:6px solid #dbe3eb;
    position:absolute;
    bottom:0;
    left:40%;
}

.el-header, .el-footer {
    line-height: 60px;

  }
  .el-header .user{
      display:inline-block;
      font-size:14px;
  }
  #DateTime{
     
      font-size:14px;
  }
  .el-aside {
        color: #333;
        text-align: center;
        padding:10px;
        display:flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        border-right:1px solid #ddd;
        margin-top:10px;
        background:#3687e1;
        border-radius: 0 5px 5px 0;
    }
    
    
    .content_item{
        width:100%;
        text-align: left;
        padding:2px;
        cursor: pointer;
        margin-top:5px;
        padding-left:10px;
        border-radius: 5px;
        background:#3687e1  !important;
        color:#fff;
        height:50px;
        line-height:40px;
    }
   
    .content_item:hover{
        background:#3379d6 !important;
    }
    .content_item img{
        margin-top:5px;
        height:48px;
    }
    .content_item div{
        font-size:14px;
        margin-top:5px;
       /* text-shadow:#e6e3e3 0.1em 0.1em 0.2em;*/
    }
  

  
  .el-main {
   /* background-color: #E9EEF3;*/
    overflow:hidden;
    padding:0;
    display:flex;
    flex-direction: column;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    overflow:hidden;
    margin-top:10px;
    padding-left:10px;
    padding-right:10px;
    padding-bottom:10px;
  }
  .el-main-content{
     
      flex:1;
      display:flex;
      flex-direction: column;
      box-sizing: border-box;
      -moz-box-sizing: border-box;
      -webkit-box-sizing: border-box;
      overflow:hidden;
      background:#f8fafb;
      border-radius: 5px;
  }
  .el-tabs{
      display:flex;
      flex-direction: column;
      height:46px;
  }
  .el-tabs__content2{
      flex:1;
      display:flex;
      flex-direction: column;
      overflow:hidden;
      border-radius: 5px 5px 0 0;
      padding-top:10px;
  }
  .el-tabs__content{
      height:0;
  }
  .headers{
      height:30px;
      line-height:30px;
      box-sizing: border-box;
      -moz-box-sizing: border-box;
      -webkit-box-sizing: border-box;
      padding-top:15px;
      padding-left:20px;
  }
  iframe{
      flex:1;
  }
  
  body > .el-container {
    margin-bottom: 40px;
    height:100%;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
  ::-webkit-scrollbar{
    width: 7px;
    height: 7px;
    background-color: #F5F5F5;
  }

  /*定义滚动条轨道 内阴影+圆角*/
  ::-webkit-scrollbar-track {
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    background-color: #F5F5F5;
  }

  /*定义滑块 内阴影+圆角*/
  ::-webkit-scrollbar-thumb{
    border-radius: 10px;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
    background-color: #c8c8c8;
  }
  .el-collapse{
      width:100%;
    
      box-sizing: border-box;
      -moz-box-sizing: border-box;
      -webkit-box-sizing: border-box;
  }
</style>
<style >
    .el-collapse-item__wrap{
        background-color:#3687e1  !important;
        border-bottom:0  !important;
    }
    .el-collapse-item__header{
         background-color:#3687e1  !important;
         color:#fff !important;
    }
    .el-collapse{
        border-top:0 !important;
        border-bottom:0 !important;
    }
    .el-tabs__nav-scroll{
        background:#e1e9f1;
         padding-left:10px !important;
    }
    .el-tabs__item{
        color:#778ca2 !important;
        font-size:12px !important;
        margin-left:5px;
        background:#d3dfeb;
        border-radius: 5px 5px 0 0;
        height:30px !important;
        line-height:30px !important;
        vertical-align:bottom;
    }
    .el-tabs__item.is-active{
        color:#778ca2 !important;
        font-size:12px;
        background:#f8fafb;
        height:40px !important;
        line-height:40px !important;
    }
</style>